<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <input type="checkbox" class="checkbox">
    <style>
        body {
           display: flex;
           align-items: center;
           justify-content: center;
           min-height: 100vh;
           margin: 0;
           padding: 0;
           background-color: #34495e;
        }
        input.checkbox{
            outline: none;
            margin: 0;
            padding: 0;
            border: none;
            appearance: none;
            background-color: rgba(100,100,100,1);
            border-radius:50px;
            width: 175px;
            height: 80px;
            position: relative;
            transform: all .5s ease-in-out;
        }
        input.checkbox::after{
            content: '';
            position: absolute;
            border-radius:50%;
            top: 10px;
            left: 10px;
            width: 60px;
            height: 60px;
            background: #fff;
            transform: all .5s ease-in-out;
        }
        input.checkbox::before{
            content: '';
            position: absolute;
            width: 100%;
            height: 100%;
            margin: 0;
            padding: 0;
            position: flex;
            top: 0;
            left: 0;
            background: #fff;
            transform: all .5s ease-in-out;
        }
        input.checkbox:checked{
            background: rgba(0,200,0,1);
        }
        input.checkbox:checked::after{
            left: 105px;
        }
        input.checkbox:checked::before{
            background: #333;
            /*z-index: -1;*/
        }
    </style>
</body>
</html>
<!-- https://www.bilibili.com/video/BV16T4y1Z7Zq/?spm_id_from=333.999.0.0&vd_source=c9bd0b350867db7a7323e641408a3eae -->